package ar.com.temporis.framework.comparator;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import ar.com.temporis.framework.AbstractERPJTestCase;
import ar.com.temporis.framework.common.comparator.BeanComparator;

/**
 * Tests complex cases like composite beans.
 *
 * @author raul.bajales@gmail.com
 */
public class BeansVerifierTestsComplexCases extends AbstractERPJTestCase {
  
  Log logger = LogFactory.getLog(BeansVerifierTestsComplexCases.class);

  /**
   * Both beans contain the same data but are different instances.
   */
  public void testEqualBeans() {
    BeanComparator comparator = (BeanComparator) applicationContext.getBean("beanComparator");
    comparator.compare(SampleBeansFactory.getFullModel1(),
        SampleBeansFactory.getFullModel1());
    assertTrue(comparator.comparisonResult());
    assertNull(comparator.getLog());
  }

  /**
   * Each bean contain different data.
   */
  public void testDifferentBeans() {
    BeanComparator comparator = (BeanComparator) applicationContext.getBean("beanComparator");
    comparator.compare(SampleBeansFactory.getFullModel1(),
        SampleBeansFactory.getFullModel2());
    assertFalse(comparator.comparisonResult());
    assertNotNull(comparator.getLog());
    logger.debug(comparator.getLog());
  }
}
